import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:数组中只出现一次的两个数字
 * User: wangxin
 * Date: 2024-12-22
 * Time: 20:50
 */
public class Test2 {
    public int[] FindNumsAppearOnce (int[] nums) {
        // write code here
        Map<Integer,Integer> map = new HashMap<Integer,Integer>();
        for(int i = 0;i < nums.length;i++){
            if(map.containsKey(nums[i])){
                map.put(nums[i],map.get(nums[i])+1);
            }else{
                map.put(nums[i],1);
            }
        }
        int[] res = new int[2];
        int i = 0;
        for(Map.Entry<Integer,Integer> entry:map.entrySet()){
            if(entry.getValue()<2){
                res[i] = entry.getKey();
                i++;
            }
        }
        Arrays.sort(res);
        return res;
    }
}
